<template>
  <el-dialog
    width="800px"
    :visible.sync="dialogVisible"
    :title="title"
    :append-to-body="true"
    @callBack="onCallBack"
    @close="onClose"
  >
    <table class="tb-table">
      <tr>
        <td class="tb-title" width="15%">处罚名称:</td>
        <td colspan="3" width="85%">{{ form.name }}</td>
      </tr>
      <tr>
        <td class="tb-title" width="15%">处罚类型:</td>
        <td colspan="3" width="85%">
          <span v-if="form.type === '1'">烟草处罚</span>
          <span v-if="form.type === '2'">专家评标</span>
          <span v-if="form.type === '3'">业主屏蔽</span>
        </td>
      </tr>
      <tr>
        <td class="tb-title" width="15%">处罚详情:</td>
        <td colspan="3" width="85%">
          <span>{{ form.context }}</span>
        </td>
      </tr>
      <tr>
        <td class="tb-title" width="15%">创建时间:</td>
        <td width="35%">
          {{ form.createTime }}
        </td>
        <td class="tb-title" width="15%">更新时间:</td>
        <td width="35%">
          {{ form.updateTime }}
        </td>
      </tr>
      <tr>
        <td class="tb-title" width="15%">创建人:</td>
        <td width="35%">
          {{ form.creatorName }}
        </td>
        <td class="tb-title" width="15%">更新人:</td>
        <td width="35%">
          {{ form.modifierName }}
        </td>
      </tr>
    </table>
  </el-dialog>
</template>

<script>
import { getOne } from '@/api/sysPunish'

export default {
  data() {
    return {
      dialogVisible: false,
      title: '添加',
      form: {
        id: ''
      }
    }
  },
  methods: {
    onShow(id) {
      if (id) {
        this.form.id = id
        this.init()
      }
      this.title = '处罚经历'
      this.dialogVisible = true
    },
    init() {
      getOne(this.form.id).then(res => {
        if (res.code === 20000) {
          this.form = res.data
        }
      })
    },
    onClose() {
      this.form = this.$options.data().form
      this.dialogVisible = false
    },
    onSubmit() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          save(this.form)
            .then((res) => {
              if (res && res.code === 20000) {
                this.$message({
                  message: '操作成功',
                  type: 'success'
                })
                this.dialogVisible = false
                this.onCallBack()
              }
            })
            .catch((e) => {
            })
        } else {
          return false
        }
      })
    },
    onCallBack() {
      this.$emit('onCallBack')
    }
  }
}
</script>

<style scoped>

.main-select-el-tree .el-tree-node .is-current > .el-tree-node__content {
  font-weight: bold;
  color: #409eff;
}

.main-select-el-tree .el-tree-node.is-current > .el-tree-node__content {
  font-weight: bold;
  color: #409eff;
}
</style>
